<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
</head>

<style> .layui-form-label {
    width: 150px !important;
    text-align: center !important;
}

</style>

<body>
    <div class="layuimini-container">
        <div class="layuimini-main">

            <fieldset class="table-search-fieldset">
                <legend>搜索信息</legend>
                <div style="margin: 10px 10px 10px 10px">
                    <form class="layui-form layui-form-pane" action="">
                        <div class="layui-form-item">
                            <div class="layui-row-sapce5">

                                <div class="layui-col">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">患者姓名</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="realName" id = "realName" autocomplete="off" class="layui-input" lay-verify="realName">
                                        </div>
                                    </div>
        
                                    <div class="layui-inline">
                                        <label class="layui-form-label">患者手机号</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="phoneNum" id = "phoneNum" autocomplete="off" class="layui-input" lay-verify="phoneNum">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">起搏器名称</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="pacemakerName" id = "pacemakerName" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">是否起搏器依赖</label>
                                        <div class="layui-input-inline">
                                            <select name="pacemakerDepend" id = "pacemakerDepend">
                                                <option value=''>全部</option>
                                                <option value='1'>是</option>
                                                <option value='2'>否</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">随访进度</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="followPace" id = "followPace" autocomplete="off" class="layui-input" lay-verify="followPace">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">下次随访时间</label>
                                        <div class="layui-input-inline" style="width: 30%;">
                                            <input type="text" class="layui-input date-time" autocomplete="off" name="nextTimeMin"
                                                placeholder="yyyy-MM-dd HH:mm:ss" lay-verify="datetime">
                                        </div>
                                        <div class="layui-form-mid">-</div>
                                        <div class="layui-input-inline" style="width: 30%;">
                                            <input type="text" class="layui-input date-time" autocomplete="off" name="nextTimeMax"
                                                placeholder="yyyy-MM-dd HH:mm:ss" lay-verify="datetime">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">已经随访次数</label>
                                        <div class="layui-input-inline" style="width: 30%;">
                                            <input type="text" name="followCountsMin" lay-verify="integer" placeholder=""
                                                autocomplete="off" class="layui-input">
                                        </div>
                                        <div class="layui-form-mid">-</div>
                                        <div class="layui-input-inline" style="width: 30%;">
                                            <input type="text" name="followCountsMax" lay-verify="integer" placeholder=""
                                                autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label id="form_submit_1" type="submit" lay-submit lay-filter="data-search-btn"
                                            class="layui-btn">点击搜索</label>
                                    </div>
                                </div>
                                <fieldset class="layui-elem-field layui-field-title">
                                    <legend><a class="layui-form-mid layui-word-aux" style="font-size: 15px; cursor:pointer;" name="color-design" onclick="highVisable()">高级搜索</a></legend>
                                </fieldset>
                                <div class="layui-col layui-hide" id = "high_search">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">id号</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="id" id = "id" autocomplete="off" class="layui-input" lay-verify="id">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">家属手机号</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="dependentNum" id = "dependentNum" autocomplete="off" class="layui-input" lay-verify="phoneNum">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">身份证号</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="idNumber" id = "idNumber" autocomplete="off" class="layui-input" lay-verify="idNumber">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">植入原因</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="reason" id = "reason" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">起搏器型号</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="pacemakerModelNumber" id = "pacemakerModelNumber" autocomplete="off" class="layui-input" lay-verify="pacemaker_m_pNumber">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">起搏器序列号</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="pacemakerProductNumber" id = "pacemakerProductNumber" autocomplete="off" class="layui-input" lay-verify="pacemaker_m_pNumber">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">起搏器公司名</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="pacemakerCompanyName" id = "pacemakerCompanyName" autocomplete="off" class="layui-input" lay-verify="pacemakerCompanyName">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">医生姓名</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="doctorName" id = "doctorName" autocomplete="off" class="layui-input" lay-verify="realName">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">医生工号</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="doctorWorkNumber" id = "doctorWorkNumber" autocomplete="off" class="layui-input" lay-verify="workNumber">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">植入时间</label>
                                        <div class="layui-input-inline" style="width: 30%;">
                                            <input type="text" class="layui-input date-time" autocomplete="off" name="createTimeMin"
                                                placeholder="yyyy-MM-dd HH:mm:ss" lay-verify="datetime">
                                        </div>
                                        <div class="layui-form-mid">-</div>
                                        <div class="layui-input-inline" style="width: 30%;">
                                            <input type="text" class="layui-input date-time" autocomplete="off" name="createTimeMax"
                                                placeholder="yyyy-MM-dd HH:mm:ss" lay-verify="datetime">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">手术者姓名</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="surgeonName" id = "surgeonName" autocomplete="off" class="layui-input" lay-verify="realName">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">手术者工号</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="surgeonWorkNumber" id = "surgeonWorkNumber" autocomplete="off" class="layui-input" lay-verify="workNumber">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">植入医院</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="hospital" id = "hospital" autocomplete="off" class="layui-input" lay-verify="hospital">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label id="form_submit_2" type="submit" lay-submit lay-filter="data-search-btn"
                                            class="layui-btn">点击搜索</label>
                                    </div>
                                </div>
                            </div>

                            
                        </div>
                    </form>
                </div>
            </fieldset>

            <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-sm data-add-btn" lay-event="add"> 添加 </button>
                <button id="deleteBtn" class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除 </button>
                <button id="method_state" class="layui-btn layui-btn-sm layui-btn-primary" style="display: none;"></button>
                <button id="table_tip" class="layui-btn layui-btn-sm layui-btn-primary" >点击修改详情</button>
                <button id="table_tip" class="layui-btn layui-btn-sm layui-btn-primary" >右侧可自定义筛选列</button>
            </div>
        </script>

            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
            <script type="text/html" id="currentTableBar">
            <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
            <a class="layui-btn layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
        </script>

        </div>
    </div>

    <script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <script src="../../js/basic-load.js" charset="utf-8"></script>
    <script>
        urlfront = url_basic
        var this_privilege = -1

        layui.use(['form', 'table', 'laydate'], function () {
            var $ = layui.jquery,
                form = layui.form,
                laydate = layui.laydate,
                table = layui.table;
            
            
    
            var datatime_elems = document.getElementsByClassName("date-time")
            for (var i = 0; i < datatime_elems.length; i++) {
                laydate.render({
                    elem: datatime_elems[i]
                    , type: 'datetime'
                });
            }
            // $.ajax({    // 获取权限用户名等信息
            //     url: "http://192.168.1.100:5003/member/user/info",
            //     type: "POST",
            //     data: {},
            //     success: function (data, textStatus) {
            //         //console.log(data)
            //         //console.log(textStatus)
            //         this_privilege = data.privilege
            //     },
            //     error: function (xhr, errorText, errorType) {
            //         //console.log(xhr.status)
            //         //console.log(errorType)
            //     },
            //     complete: function () {
            //     },
            //     dataType: "json"
            // })
            form.verify({
            // 通用限制
                //id不超过20个字符
                id: [
                    /^(\d{0,20})?$/
                    , '最大长度不超过20位数'
                ]
                //手机号为11位手机号
                ,phoneNum:[
                    /^(\d{0,,11})?$/
                    , '请正确输入不超过11位的手机号'
                ]
            //普通搜索限制
                //姓名不超过33个字符
                ,realName:function (value) {
                    if (value.length > 33) {
                    return '最大长度不超过33个字符';
                    }
                }
                //随访阶段不超过10个字符
                ,followPace:function (value) {
                    if (value.length > 10) {
                    return '最大长度不超过10个字符';
                    }
                }
            //高级搜索限制
                //身份证号限制
                ,idNumber:[
                    /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$|^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}[0-9Xx]|^(\d{0})?$/
                    , '请正确输入15位或18位身份证号'
                ]
                //植入原因不超过20个字符
                ,reason:function (value) {
                    if (value.length > 20) {
                    return '最大长度不超过20个字符';
                    }
                }
                //详细介绍、手术过程不超过32767个字符
                ,intro_detail:function (value) {
                    if (value.length > 32767) {
                    return '输入字符超过最大限制！';
                    }
                }
                //医院名称
                ,hospital:function (value) {
                    if (value.length > 33) {
                    return '最大长度不超过33个字符';
                    }
                }
            //不在数据表里的搜索限制
                //起搏器序列号和型号
                ,pacemaker_m_pNumber:function (value) {
                    if (value.length > 10) {
                    return '最大长度不超过10个字符';
                    }
                }
                //起搏器公司名
                ,pacemakerCompanyName:function (value) {
                    if (value.length > 33) {
                    return '最大长度不超过33个字符';
                    }
                }
                //填表医生、手术者工号
                , workNumber: [
                    /^(\d{0,11})?$/
                    , '请输入不超过11位的工号'
                ]
            });
            table.render({
                elem: '#currentTableId',
                autoSort: true,
                url:   `${url_basic}/medicalRecords/search`,
                method: 'post',
                contentType: 'application/json',
                toolbar: '#toolbarDemo',
                skin: 'line',
                even: true,
                size: 'lg',
                defaultToolbar: ['filter', 'exports', 'print', {
                    title: '提示',
                    layEvent: 'LAYTABLE_TIPS',
                    icon: 'layui-icon-tips'
                }],
                cols: [[
                    { type: "checkbox", minWidth: 50 },
                    { field: 'id', minWidth: 100, title: 'id号', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true },
                    { field: 'realName', minWidth: 100, title: '患者姓名', event: 'medicalRecordsDetail', style: 'cursor: pointer;', sort: true },
                    { field: 'phoneNum', minWidth: 100, title: '患者手机号', event: 'medicalRecordsDetail', style: 'cursor: pointer;', sort: true },
                    { field: 'idNumber', minWidth: 100, title: '身份证号', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true },
                    { field: 'dependentNum', minWidth: 100, title: '家属手机号', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true },
                    { field: 'reason', minWidth: 100, title: '植入原因', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true },
                    { field: 'pacemakerId', minWidth: 100, title: '起搏器Id', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true },
                    { field: 'pacemakerName', minWidth: 100, title: '起搏器名称', event: 'medicalRecordsDetail', style: 'cursor: pointer;', sort: true },
                    { field: 'pacemakerModelNumber', minWidth: 100, title: '起搏器型号', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true },
                    { field: 'pacemakerProductNumber', minWidth: 100, title: '起搏器序列号', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true },
                    { field: 'pacemakerCompanyName', minWidth: 100, title: '起搏器公司名', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true },
                    { field: 'pacemakerDepend', minWidth: 100, title: '是否起搏器依赖', event: 'medicalRecordsDetail', style: 'cursor: pointer;', sort: true,templet : function(d){
                        if(d.pacemakerDepend == 1)
                            return "是"
                        if(d.pacemakerDepend == 2)
                            return "否"
                    } },
                    { field: 'introduce', minWidth: 100, title: '详细介绍', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true },
                    { field: 'doctorId', minWidth: 100, title: '填表医生Id', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true },
                    { field: 'doctorName', minWidth: 100, title: '医生姓名', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true },
                    { field: 'doctorWorkNumber', minWidth: 100, title: '医生工号', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true },
                    { field: 'createTime', minWidth: 100, title: '植入时间', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true, templet: "<div>{{layui.util.toDateString(d.createTime, 'yyyy-MM-dd HH:mm:ss')}}</div>" },
                    { field: 'surgeon', minWidth: 100, title: '手术者Id', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true },
                    { field: 'surgeonName', minWidth: 100, title: '手术者姓名', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true },
                    { field: 'surgeonWorkNumber', minWidth: 100, title: '手术者工号', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true },
                    { field: 'hospital', minWidth: 100, title: '植入医院', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true },
                    { field: 'surgicalDetail', minWidth: 100, title: '手术过程', event: 'medicalRecordsDetail', style: 'cursor: pointer;',hide: true, sort: true },
                    { field: 'nextTime', minWidth: 100, title: '下次随访时间', event: 'medicalRecordsDetail', style: 'cursor: pointer;', sort: true, templet: "<div>{{layui.util.toDateString(d.nextTime, 'yyyy-MM-dd HH:mm:ss')}}</div>"},
                    { field: 'followCounts', minWidth: 100, title: '已经随访次数', event: 'medicalRecordsDetail', style: 'cursor: pointer;', sort: true },
                    { field: 'followPace', minWidth: 100, title: '随访进度', event: 'medicalRecordsDetail', style: 'cursor: pointer;', sort: true },
                ]],
                limits: [10, 15, 20, 25, 50, 100],
                limit: 15,
                page: true,
                skin: 'line'
            });
            table.on('sort(currentTableFilter)', function (obj) { //注：sort 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"

                //尽管我们的 table 自带排序功能，但并没有请求服务端。
                //有些时候，你可能需要根据当前排序的字段，重新向服务端发送请求，从而实现服务端排序，如：
                table.reload('currentTableId', {
                    initSort: obj //记录初始排序，如果不设的话，将无法标记表头的排序状态。
                    , where: { //请求参数（注意：这里面的参数可任意定义，并非下面固定的格式）
                        sort_field: obj.field, //排序字段
                        sort_order: obj.type //排序方式
                    }
                });
                // layer.msg('服务端排序。order by ' + obj.field + ' ' + obj.type);
            });

            // 监听搜索操作
            like_search_param = ['id','realName','phoneNum'
            ,'dependentNum','idNumber','reason'
            ,'pacemakerId','pacemakerName','pacemakerModelNumber'
            ,'pacemakerProductNumber','pacemakerCompanyName','pacemakerDepend'
            ,'introduce','doctorId','doctorName','doctorWorkNumber'
            ,'surgeon','surgeonName','surgeonWorkNumber','hospital','surgicalDetail','followPace']
            data_search_param = ['nextTime','createTime']
            int_search_param = ['followCounts']
            form.on('submit(data-search-btn)', function (data) {
                for (var key in data.field) {
                    if (data.field[key] === '')
                        delete data.field[key]
                    else if (like_search_param.indexOf(key) > -1)
                        data.field[key + '-op'] = 'ct'
                }
                for (var key in int_search_param) {
                    if (data.field[int_search_param[key] + "Min"] != null)
                        if (data.field[int_search_param[key] + "Max"] != null) {
                            data.field[int_search_param[key] + "-op"] = "bt"
                            data.field[int_search_param[key] + "-0"] = parseInt(data.field[int_search_param[key] + "Min"])
                            data.field[int_search_param[key] + "-1"] = parseInt(data.field[int_search_param[key] + "Max"])
                            if(data.field[int_search_param[key] + "-0"] > data.field[int_search_param[key] + "-1"]){
                                layer.msg('范围查询输入下界应小于上界');
                                return false
                            }
                            delete data.field[int_search_param[key]]
                        } else {
                            data.field[int_search_param[key]] = parseInt(data.field[int_search_param[key] + "Min"])
                            data.field[int_search_param[key] + "-op"] = "ge"
                        }
                    else if (data.field[int_search_param[key] + "Max"] != null) {
                        data.field[int_search_param[key]] = parseInt(data.field[int_search_param[key] + "Max"])
                        data.field[int_search_param[key] + "-op"] = "le"
                    }
                    delete data.field[int_search_param[key] + "Min"]
                    delete data.field[int_search_param[key] + "Max"]
                }
                for (var key in data_search_param) {
                    if (data.field[data_search_param[key] + "Min"] != null)
                        if (data.field[data_search_param[key] + "Max"] != null) {
                            data.field[data_search_param[key] + "-op"] = "bt"
                            data.field[data_search_param[key] + "-0"] = data.field[data_search_param[key] + "Min"]
                            data.field[data_search_param[key] + "-1"] = data.field[data_search_param[key] + "Max"]
                            var stdt = new Date(data.field[data_search_param[key] + "-0"].replace("-","/"));
                            var etdt = new Date(data.field[data_search_param[key] + "-1"].replace("-","/"));
                            if(stdt > etdt){
                                layer.msg('范围查询输入下界应小于上界');
                                return false
                            }
                            delete data.field[data_search_param[key]]
                        } else {
                            data.field[data_search_param[key]] = data.field[data_search_param[key] + "Min"]
                            data.field[data_search_param[key] + "-op"] = "ge"
                        }
                    else if (data.field[data_search_param[key] + "Max"] != null) {
                        data.field[data_search_param[key]] = data.field[data_search_param[key] + "Max"]
                        data.field[data_search_param[key] + "-op"] = "le"
                    }
                    delete data.field[data_search_param[key] + "Min"]
                    delete data.field[data_search_param[key] + "Max"]
                }
                var result = JSON.stringify(data.field);
                //执行搜索重载
                table.reload('currentTableId', { where: data.field });
            });
            area1 = document.body.offsetWidth < 800 ? '100%' : '800px'
            table.on('toolbar(currentTableFilter)', function (obj) {
                if (obj.event === 'delete') {  // 监听删除操作
                    var checkStatus = table.checkStatus('currentTableId')
                        , data = checkStatus.data;
                    var tmp = [];
                    for (var i = 0; i < data.length; i++) {
                        tmp.push(data[i].id);
                    }
                    if(tmp.length < 1) return;
                    $.ajax({
                        url: urlfront + "/medicalRecords/delete",
                        type: "POST",
                        data: JSON.stringify(tmp),
                        contentType: 'application/json',
                        success: function (data, textStatus) {
                            if (data.code == 0) {
                                layer.msg('删除成功', { time: 0.5 * 1000 }, function () { });
                            }
                            else {
                                layer.msg('删除失败，原因：' + data.msg);
                            }
                        },
                        error: function (xhr, errorText, errorType) {
                            layer.msg('删除失败（与服务器连接失败）');
                        },
                        complete: function () {
                            table.reload('currentTableId'); //只重载数据
                        },
                        dataType: "json"
                    })
                }else if (obj.event === 'add') {  // 监听添加操作
                    area1 = document.body.offsetWidth < 800 ? '100%' : '800px'
                    var index = layer.open({
                        title: '新建随访档案信息',
                        type: 2,
                        shade: 0.2,
                        maxmin: true,
                        shadeClose: true,
                        area: [area1, '100%'],
                        content: './add.html',
                        success: function (layero, index) {
                            var iframeWin = window[layero.find('iframe')[0]['name']] // //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                            iframeWin.setData(null, this_privilege)
                        },
                        end: function () {
                            table.reload('currentTableId'); //只重载数据
                        }
                    });
                    $(window).on("resize", function () {
                        layer.full(index);
                    });
                }
            });

            //监听表格复选框选择
            table.on('checkbox(currentTableFilter)', function (obj) {
            });

            table.on('tool(currentTableFilter)', function (obj) {
                var data = obj.data;
                if (obj.event === 'medicalRecordsDetail') {
                    // area1 = document.body.offsetWidth < 700 ? '100%' : '700px'
                    var index = layer.open({
                        title: '随访档案详情',
                        type: 2,
                        shade: 0.2,
                        maxmin: true,
                        shadeClose: true,
                        area: [area1, '65%'],
                        content: './detailMain.html',
                        success: function (layero, index) {
                            layer.full(index);
                            var body = layer.getChildFrame('body', index ,0);
                            var iframeWin = window[layero.find('iframe')[0]['name']] // //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                            iframeWin.setData(data, this_privilege)
                        },
                        end: function () {
                            table.reload('currentTableId')
                        }
                    });
                    $(window).on("resize", function () {
                        layer.full(index);
                    });
                    return false;
                }
            });

            var welmrId1=sessionStorage.getItem("mrId1")
            var welmrId2=sessionStorage.getItem("mrId2")
            var mrfrommain=sessionStorage.getItem("mrfrommain")
            var labelfrommain=sessionStorage.getItem("labelfrommain")
            if(labelfrommain==1){
                sessionStorage.removeItem("labelfrommain");
                sessionStorage.removeItem("mrId1");
                sessionStorage.setItem("directgotolabel",1);
                area2 = document.body.offsetWidth < 700 ? '100%' : '700px'
                $.ajax({
                    url: urlfront + "/medicalRecords/medicalRecordOne",  
                    type: "POST",
                    // url: '../../api/table.json',
                    // type: "GET",
                    data:JSON.stringify({"mrId":welmrId1}),
                    contentType: 'application/json',
                    
                    success: function (data, textStatus) {
                        var index = layer.open({
                        title: '随访档案详情',
                        type: 2,
                        shade: 0.2,
                        maxmin: true,
                        shadeClose: true,
                        area: [area2, '65%'],
                        content: './detailMain.html',
                        success: function (layero, index) {
                            layer.full(index);
                            var body = layer.getChildFrame('body', index ,0);
                            var iframeWin = window[layero.find('iframe')[0]['name']] // //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                            iframeWin.setData(data.data["0"], this_privilege)
                        },
                        end: function () {
                            table.reload('currentTableId')
                        }
                    });
                        $(window).on("resize", function () {
                            layer.full(index);
                        });
                    },
                    error: function (xhr, errorText, errorType) {
                        layer.msg('拉去信息失败');
                    },
                    complete: function () {
                        table.reload('currentTableId'); //只重载数据
                    },
                    dataType: "json"
                    })
    
                    return false;
            }
            
            if(mrfrommain==1){
                sessionStorage.removeItem("mrfrommain");
                sessionStorage.removeItem("mrId2");
                //sessionStorage.setItem("directgotolabel",2);
                area2 = document.body.offsetWidth < 700 ? '100%' : '700px'
                $.ajax({
                    url: urlfront + "/medicalRecords/medicalRecordOne",  
                    type: "POST",
                    /*
                    这里后端要加个口，前端给后端mrId，后端应该返给前端档案相关信息
                    （就和index的表格里的data一样的格式、一样的内容）
                    */
                    // url: '../../api/table.json',
                    // type: "GET",
                    data:JSON.stringify({"mrId":welmrId2}),
                    contentType: 'application/json',
                    success: function (data, textStatus) {
                        var index = layer.open({
                        title: '随访档案详情',
                        type: 2,
                        shade: 0.2,
                        maxmin: true,
                        shadeClose: true,
                        area: [area2, '65%'],
                        content: './detailMain.html',
                        success: function (layero, index) {
                            layer.full(index);
                            var body = layer.getChildFrame('body', index ,0);
                            var iframeWin = window[layero.find('iframe')[0]['name']] // //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                            iframeWin.setData(data.data["0"], this_privilege)
                        },
                        end: function () {
                            table.reload('currentTableId')
                        }
                    });
                        $(window).on("resize", function () {
                            layer.full(index);
                        });
                    },
                    error: function (xhr, errorText, errorType) {
                        layer.msg('拉去信息失败');
                    },
                    complete: function () {
                        table.reload('currentTableId'); //只重载数据
                    },
                    dataType: "json"
                    })
    
                    return false;
            }
        });

        function highVisable(){
            if(document.getElementById('high_search').classList.contains('layui-hide')){
                document.getElementById('high_search').classList.remove('layui-hide');
                document.getElementById('form_submit_1').classList.add('layui-hide');
            }else{
                document.getElementById('high_search').classList.add('layui-hide');
                document.getElementById('form_submit_1').classList.remove('layui-hide');
            }
        }
    </script>

</body>

</html>